package org.tarena.dang.action.main;

import java.sql.SQLException;
import java.util.List;
import java.util.Random;

import org.tarena.dang.action.BaseAction;
import org.tarena.dang.entity.Book;
import org.tarena.dang.service.BookService;
import org.tarena.dang.service.BookServiceImp;

public class RecomAction extends BaseAction {
	private List<Book> books;
	private int totalSize;//所有图书树 配置文件
	private int recomBookNnm;//编辑推荐图书数量

	public String execute(){
		BookService bookService = new BookServiceImp();
		int n = new Random().nextInt(totalSize-recomBookNnm);
		try {
			books = bookService.findRecomBook(n,recomBookNnm);
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return "success";
	}
	
	public List<Book> getBooks() {
		return books;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}

	public int getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public int getRecomBookNnm() {
		return recomBookNnm;
	}

	public void setRecomBookNnm(int recomBookNnm) {
		this.recomBookNnm = recomBookNnm;
	}
	
}
